package base
/*维度*/

class Dimensions {
    /*维度名称*/
    String name
    /*编码*/
    String code
    /*是否能是系统内置的,是内置的话,用户不能删除,可以编辑名称,不能编辑编号*/
    Boolean sysInit = false
    /*是否启用,非启用的下拉时不能显示出来*/
    Boolean enabled = true
    /*核算名称*/
    String accName
    /*核算编码*/
    String accCode
    /*备  注*/
    String remark

    /*创建时间*/
    Date dateCreated
    /*最后更新的时间*/
    Date lastUpdated
    static  belongsTo = [parent:Dimensions, dimensionsType:DimensionsType]
    static  hasMany = [children:Dimensions]
    static constraints = {
        sysInit nullable: true
        enabled nullable: true
        accName nullable: true
        accCode nullable: true
        remark nullable: true,maxSize: 3000
    }

    transient utilsService
    def buildDomain() {
        def b = [:] + this.properties
        def param = [allowformat: true, allowprecision: false]
        b = utilsService.truncProp(this, b, param) { amap ->
            amap << ['id': this.id]

        }
        b
    }

    def buildDomainList(list) {
        def rds = []
        list.each {
            def b = [:] + it.properties
            def param = [allowformat: true, allowprecision: false]
            b = utilsService.truncProp(it, b, param) { amap ->
                amap << ['id': it.id]
            }
            rds << b
        }
        return rds
    }
}
